//
//  STDSShaderProgram.hpp
//  STDRenderSDK
//
//  Created by 陈学明 on 2023/3/12.
//

#ifndef STDSShaderProgram_hpp
#define STDSShaderProgram_hpp

#include <Basic/graphic/STDSOpenGL.h>
#include <Basic/graphic/STDSObject.h>

using namespace std;

class STDSShaderProgram: public STDSObject {
    
public:
    STDSShaderProgram(const string &vex, const string &frg);
    
    ~STDSShaderProgram();
    
    void load(const string &vex, const string &frg);
    
    void load(const char *vex, const char *frg);
public:
    
    bool init();
    
    void destroy();
    
    void use();
    
    void unuse();
    
    int getAttrib(const char *name) const;
    
    int getUniform(const string &name) const;
    
    void setMatrix2(int id, float *matrix);

    void setMatrix2(int id, int count, float *matrix);

    void setMatrix3(int id, float *matrix);

    void setMatrix3(int id, int count, float *matrix);
    
    void setMatrix(int id, const GLfloat *value);

    void setUniform(int id, int value);

    void setUniform(int id, float value);

    void setUniform(int id, int n, float *value);

    void setUniform1iv(int id, int n, int *value);

    void setUniform1fv(int id, int n, float *value);

    void setUniform2fv(int id, int n, float *value);

    void setUniform3fv(int id, int n, float *value);

    void setUniform4fv(int id, int n, float *value);

    void setUniform2f(int id, float valueX, float valueY);

    void setUniform3f(int id, float valueX, float valueY, float valueZ);

    void setUniform4f(int id, float valueX, float valueY, float valueZ, float valueW);
    
public:
    unsigned int mProgId{0};
    bool mbInited{false};
    int64_t mActiveTime{0};

    std::string mStrVex{""};
    std::string mStrFra{""};
};
#endif /* STDSShaderProgram_hpp */
